{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf320
{\fonttbl\f0\fswiss\fcharset0 Helvetica;\f1\fnil\fcharset0 Monaco;}
{\colortbl;\red255\green255\blue255;}
{\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid1\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid1}
{\list\listtemplateid2\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid101\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid2}
{\list\listtemplateid3\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid201\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid3}}
{\*\listoverridetable{\listoverride\listid1\listoverridecount0\ls1}{\listoverride\listid2\listoverridecount0\ls2}{\listoverride\listid3\listoverridecount0\ls3}}
\margl1440\margr1440\vieww19360\viewh17460\viewkind0
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\qc\pardirnatural

\f0\b\fs24 \cf0 TimerLab
\b0 \
\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
\cf0 \
This is a sample project and test harness for the my NSTimer category.\
\
Normally, if you create an NSTimer and time is suspended (putting the machine to sleep) or changed (setting the system clock), NSTimer will try and compensate. In a sense, the time given to NSTimer is relative. The problem with this is that sometimes when you tell a timer to fire on a specific date at a specific time, you want it to fire on that specific date at that specific time. Thus, this category was created.\
\
The basic approach is to store the original fire date of the timer and re-set it whenever the machine wakes or the system clock is changed. Since at least one new instance variable is needed, it makes sense to do an NSTimer subclass. Unfortunately, NSRunLoop doesn't seem to work with anything but NSTimer directly. I suspect it's calling some private methods on NSTimer that I'm not privy to.\
\
So instead, it's done as a category. By using Snow Leopard's "associative references" ({\field{\*\fldinst{HYPERLINK "http://developer.apple.com/mac/library/documentation/cocoa/conceptual/objectivec/articles/ocAssociativeReferences.html"}}{\fldrslt http://developer.apple.com/mac/library/documentation/cocoa/conceptual/objectivec/articles/ocAssociativeReferences.html}}), I can add the equivalent of instance variables to NSTimer. And since, I was mucking with NSTimer, I also went ahead and added support for blocks.\
\
The test program allows you to test the regular behavior and the newer "absolute" behavior side by side. Set a time and click "Start timer". Now, put your machine to sleep or mess with the system clock. You'll see the regular timer adjust while the "absolute" timer will stay put.\
\
A blog post on this can be found at: {\field{\*\fldinst{HYPERLINK "http://www.noodlesoft.com/blog/2010/07/01/playing-with-nstimer/"}}{\fldrslt http://www.noodlesoft.com/blog/2010/07/01/playing-with-nstimer/}}\
\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural

\b \cf0 Notes
\b0 \
\
\pard\tx220\tx720\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\li720\fi-720\ql\qnatural\pardirnatural
\ls1\ilvl0\cf0 {\listtext	\'95	}Because of technical limitations of being a category, once you create an "absolute" timer, calling -setFireDate: may not work like how you'd want. If you need to change the fire date, create a new timer.\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
\cf0 \
\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural

\b \cf0 Possible Improvements\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural

\b0 \cf0 \
\pard\tx220\tx720\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\li720\fi-720\ql\qnatural\pardirnatural
\ls2\ilvl0\cf0 {\listtext	\'95	}Add support for repeating timers.\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
\cf0 \
\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural

\b \cf0 Contact
\b0 \
\
Just go {\field{\*\fldinst{HYPERLINK "http://www.noodlesoft.com/about.php"}}{\fldrslt www.noodlesoft.com}} and shoot me an email. Or visit the blog article linked above and leave a comment. Bugs, suggestions and other feedback appreciated.\
\
\

\b License
\b0 \
\
I am releasing this under the MIT license.\
\
____________________________________\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural

\f1 \cf0 Copyright (c) 2010 Noodlesoft, LLC. All Rights Reserved.\
\
Permission is hereby granted, free of charge, to any person\
obtaining a copy of this software and associated documentation\
files (the "Software"), to deal in the Software without\
restriction, including without limitation the rights to use,\
copy, modify, merge, publish, distribute, sublicense, and/or sell\
copies of the Software, and to permit persons to whom the\
Software is furnished to do so, subject to the following\
conditions:\
\
The above copyright notice and this permission notice shall be\
included in all copies or substantial portions of the Software.\
\
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\
OTHER DEALINGS IN THE SOFTWARE.\
\pard\tx220\tx720\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\li720\fi-720\ql\qnatural\pardirnatural
\ls3\ilvl0
\f0\b \cf0 \
}